package com.knife.autoconfigure.database.backup;

import com.knife.database.backup.KnifeDbBackUp;
import com.knife.database.backup.config.KnifeDbBackUpProperties;
import com.knife.database.backup.mysql.MySqlKnifeDbBackUp;
import com.knife.file.app.KnifeFileInfoService;
import com.knife.file.compress.KnifeFileCompress;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * 数据自动备份自动装配
 *
 * @author： 76875
 * @date： 2022/3/31 星期四 9:41
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Configuration
@EnableConfigurationProperties(value = {KnifeDbBackUpProperties.class})
@ConfigurationPropertiesScan(basePackages = "com.knife.database")
public class KnifeDbBackUpAutoConfigure {


    @Bean
    public KnifeDbBackUp dbBackUp(JdbcTemplate jdbcTemplate, KnifeDbBackUpProperties knifeDbBackUpProperties, KnifeFileCompress knifeFileCompress, KnifeFileInfoService knifeFileInfoService) {
        MySqlKnifeDbBackUp mySqlDbBackUp = new MySqlKnifeDbBackUp();
        mySqlDbBackUp.setJdbcTemplate(jdbcTemplate);
        mySqlDbBackUp.setKnifeDbBackUpProperties(knifeDbBackUpProperties);
        mySqlDbBackUp.setKnifeFileCompress(knifeFileCompress);
        mySqlDbBackUp.setKnifeFileInfoService(knifeFileInfoService);
        return mySqlDbBackUp;
    }
}
